React应用上的GoogleAnalytics(分析)不起作用 | 您所在的位置:网站首页 › android pageview › React应用上的GoogleAnalytics(分析)不起作用 |
1> Erik Martín ..: 您需要在componentDidMount和componentDidUpdate中生成综合浏览量: compOnentDidMount= () => ReactGA.pageview(window.location.pathname + window.location.search); compOnentDidUpdate= () => ReactGA.pageview(window.location.pathname + window.location.search);因此,最终代码: import React, { Component } from "react"; import HeaderList from "./components/Header"; import "./App.css"; import { Layout } from "antd"; import { Router, Route, Switch } from "react-router-dom"; import createHistory from "history/createBrowserHistory"; import ReactGA from 'react-ga'; import Keys from './config/keys'; import AboutMe from "./components/AboutMe"; import Skills from "./components/Skills"; import Contact from "./components/Contact"; import Projects from "./components/Projects"; const { Content } = Layout; ReactGA.initialize(Keys.GOOGLE_TRACKING_ID); //Unique Google Analytics tracking number class App extends Component { compOnentDidMount= () => ReactGA.pageview(window.location.pathname + window.location.search); compOnentDidUpdate= () => ReactGA.pageview(window.location.pathname + window.location.search); render() { return ( ); } } export default App; |
CopyRight 2018-2019 实验室设备网 版权所有 |